﻿using System;
using System.Collections.Generic;
using System.Linq;
using Tisbi.LawFirm.DAL.Models;

namespace Tisbi.LawFirm.UI.ViewModel
{
    public class EmployeeCRUDViewModal : BaseCRUDItemViewModel<Employees>
    {
        public EmployeeCRUDViewModal(Employees model) : base(model)
        {
        }

        public Role SelectedRole
        {
            get { return Model.Role; }
            set
            {
                Model.Role = value;
                RaisePropertyChanged(() => SelectedRole);
            }
        }

        public IEnumerable<Role> Roles
        {
            get
            {
                var roles = Enum.GetValues(typeof(Role)).Cast<Role>();
                SelectedRole = Role.User;
                return roles;
            }
        }

        public Gender SelectedGender
        {
            get { return Model.Gender; }
            set
            {
                Model.Gender = value;
                RaisePropertyChanged(() => SelectedRole);
            }
        }

        public IEnumerable<Gender> Genders
        {
            get
            {
                var genders = Enum.GetValues(typeof(Gender)).Cast<Gender>();
                SelectedGender = Gender.Мужской;
                return genders;
            }
        }

        public string ShortFio {
            get { return Model.ShortFio; }
            set
            {
                Model.ShortFio = value;
                RaisePropertyChanged(() => ShortFio);
            }
        }

        public override string Error
        {
            get { return this["ShortFio"]; }
        }

        public override string this[string columnName]
        {
            get
            {
                string result = string.Empty;
                switch (columnName)
                {
                    case "ShortFio":
                        if (string.IsNullOrWhiteSpace(Model.ShortFio)) result = "Поле 'Короткое ФИО' обязательное";
                        break;
                }
                return result;
            }
        }
    }
}
